/*
 *
 * Version 1.00
 * 
 * Created on 2007-6-4
 * Encoding UTF-8
 */
package net.comm.user.web.action;

import java.util.ArrayList;
import java.util.Calendar;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import net.comm.blog.service.impl.BlogServiceImpl;
import net.comm.blog.web.form.BlogForm;
import net.comm.common.Decode;
import net.comm.common.GlbFinal;
import net.comm.common.ReturnMessage;
import net.comm.friend.bean.BaseFriend;
import net.comm.friend.service.impl.FriendServiceImpl;
import net.comm.friend.service.impl.LinjuServiceImpl;
import net.comm.friend.web.form.FriendForm;
import net.comm.friend.web.form.LinjuForm;
import net.comm.group.service.impl.GAlbumServiceImpl;
import net.comm.group.service.impl.GMemberServiceImpl;
import net.comm.group.web.form.GAlbumForm;
import net.comm.group.web.form.GMemberForm;
import net.comm.message.bean.BaseMessage;
import net.comm.message.service.impl.MessageServiceImpl;
import net.comm.message.web.form.MessageForm;
import net.comm.oper.bean.Baseoperlog;
import net.comm.oper.service.impl.NotAdvServiceImpl;
import net.comm.oper.service.impl.OperLogServiceImpl;
import net.comm.oper.web.form.NotAdvForm;
import net.comm.oper.web.form.OperLogForm;
import net.comm.page.PageCtr;
import net.comm.user.bean.UserConstant;
import net.comm.user.service.impl.ContactsServiceImpl;
import net.comm.user.service.impl.DetailsServiceImpl;
import net.comm.user.service.impl.UserHomeServiceImpl;
import net.comm.user.service.impl.UserSysinfoServiceImpl;
import net.comm.user.service.impl.UsersServiceImpl;
import net.comm.user.service.impl.VistorLogServiceImpl;
import net.comm.user.web.form.ContactsForm;
import net.comm.user.web.form.DetailsForm;
import net.comm.user.web.form.UserHomeForm;
import net.comm.user.web.form.UserSysinfoForm;
import net.comm.user.web.form.UsersForm;
import net.comm.user.web.form.VistorLogForm;
import net.comm.util.DatetimeUtil;
import net.comm.util.HtmlMessageBox;
import net.comm.web.base.AbstractBaseAction;

import org.apache.commons.beanutils.BeanUtils;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;


/**
 *用户Action
 * @author hcgong(hcgong@sina.com)
 * @version 1.0
 * @date 2007-6-4
 */
public class UsersAction extends AbstractBaseAction {
	
	private UsersServiceImpl service = null;
	
	/**
	 * struct-config中该ACTION中的每个forward的常量定义
	 */
	final String LIST_FORWARD = "list";
	final String HOME_FORWARD = "home";
	final String MAIN_FORWARD = "main";
	final String ADLIST_FORWARD = "adlist";
	final String INDEX_FORWARD = "index";
	final String PWD_FORWARD = "pwd";
	final String OPER_FORWARD = "oper";
	final String LOGIN_FORWARD = "loginFwd";
	final String SENDMAIL_FORWARD = "sendmail";
	final String RESENDMAIL_FORWARD = "resendmail";
	
	
	/**
	 *构造方法
	 */
	public UsersAction()
	{
		super(false);
		
		/**
		 * 初始化业务组件接口
		 */
		service = new UsersServiceImpl();
	}
	
	/**
	 * 默认动作
	 * 1.action值为空的时候,进入查询页面
	 * 2.每个操作都执行的代码,但是方法必须返回null
	 * @param mapping	 跳转的mapping值	
	 * @param request	 HttpServletRequest对象
	 * @param response	 HttpServletResponse对象
	 */
	public ActionForward startAction(ActionMapping mapping, ActionForm form,
									 HttpServletRequest request , 
									 HttpServletResponse response)
	{
		String action = getReqParam(request , ACTION_KEY);
		if(action == null || action.trim().length() == 0) {
			return mapping.findForward(INDEX_FORWARD);
		} else {
			return null;
		}
	}	

	/**
	 * 查询档案视图清单
	 * @param mapping		跳转的mapping值		
	 * @param request		HttpServletRequest对象
	 * @param response		HttpServletResponse对象
	 * @return
	 * @throws Exception
	 */
	public ActionForward list(ActionMapping mapping, ActionForm form,
							  HttpServletRequest request , 
							  HttpServletResponse response) 
		throws Exception
	{
		/**
		 *定义一个查询bean保存查询页面提交的查询条件
		 */
		UsersForm theForm = (UsersForm)form;
			
		// 生成分页对象	
		theForm.setPage(this.getPageFromReq(request));
		
		ReturnMessage msg  = new ReturnMessage();
		
		/**
		 *赋值查询条件
		 */
		theForm.setStatus(GlbFinal.STS_NORMAL);
		
		/**
		 * 设置当前页面key和上页lastKey
		 */
		theForm.setLastKey(getReqParam(request, KEY));
		
		/**
		 *调用services中的方法
		 */
		List list = service.list(theForm , msg);
		if(msg.getErrCode() != GlbFinal.ERRCODE_SUCCESS) 
		{
			HtmlMessageBox hmb = new HtmlMessageBox();
			hmb.setAlertType(HtmlMessageBox.ALERTTYPE_CALLALERTMETHOD);
			hmb.setPrintMessage(msg.getMsg());
			hmb.setForwardUrl("javascript:history.go(-1)");
			return showMsg(hmb , request , response , mapping);
		}

		/**
		 *设置列表的数据
		 */
		setAction(request, "list");
		request.setAttribute("userlist" , list);
		request.setAttribute("theForm", theForm);
		
		/**
		 * 设置分页对象,key,lastkey到request中
		 * 使用分页组件,必须设置这三个值
		 */
		request.setAttribute(PAGE_KEY , theForm.getPage());
		request.setAttribute(KEY , theForm.getKey());
		request.setAttribute(LAST_KEY , theForm.getLastKey());
		
		/**
		 * 转发到LIST_FORWARD指定的jsp文件
		 */
		return mapping.findForward(LIST_FORWARD);
	}
	
	/**
	 * 后台查询清单
	 * @param mapping		跳转的mapping值		
	 * @param request		HttpServletRequest对象
	 * @param response		HttpServletResponse对象
	 * @return
	 * @throws Exception
	 */
	public ActionForward adlist(ActionMapping mapping, ActionForm form,
							  HttpServletRequest request , 
							  HttpServletResponse response) 
		throws Exception
	{
		/**
		 *定义一个查询bean保存查询页面提交的查询条件
		 */
		UsersForm theForm = (UsersForm)form;
			
		// 生成分页对象	
		theForm.setPage(this.getPageFromReq(request,40));
		
		ReturnMessage msg  = new ReturnMessage();
		
		/**
		 * 设置当前页面key和上页lastKey
		 */
		theForm.setLastKey(getReqParam(request, KEY));
		/**
		 *调用services中的方法
		 */
		List list = service.adlist(theForm , msg);
		if(msg.getErrCode() != GlbFinal.ERRCODE_SUCCESS) 
		{
			HtmlMessageBox hmb = new HtmlMessageBox();
			hmb.setAlertType(HtmlMessageBox.ALERTTYPE_CALLALERTMETHOD);
			hmb.setPrintMessage(msg.getMsg());
			hmb.setForwardUrl("javascript:history.go(-1)");
			return showMsg(hmb , request , response , mapping);
		}
		/**
		 *设置列表的数据
		 */
		setAction(request, "adlist");
		request.setAttribute("userlist" , list);
		request.setAttribute("theForm", theForm);
		
		/**
		 * 设置分页对象,key,lastkey到request中
		 * 使用分页组件,必须设置这三个值
		 */
		request.setAttribute(PAGE_KEY , theForm.getPage());
		request.setAttribute(KEY , theForm.getKey());
		request.setAttribute(LAST_KEY , theForm.getLastKey());
		
		/**
		 * 转发到LIST_FORWARD指定的jsp文件
		 */
		return mapping.findForward(ADLIST_FORWARD);
	}	
	
	
	/**
	 * 会员中心 个人主页
	 * @param mapping		跳转的mapping值		
	 * @param request		HttpServletRequest对象
	 * @param response		HttpServletResponse对象
	 * @return
	 * @throws Exception
	 */
	public ActionForward home(ActionMapping mapping, ActionForm form,
							  HttpServletRequest request , 
							  HttpServletResponse response) 
		throws Exception
	{
		/**
		 *定义一个查询bean保存查询页面提交的查询条件
		 */
		UsersForm theForm = (UsersForm) form;
		ReturnMessage msg  = new ReturnMessage();
		
		//取得会员隐私设置表
//		UserSetForm setForm = new UserSetForm();
//		setForm.setUserID(theForm.getUserID());
//		
//		UserSetServiceImpl setservice = new UserSetServiceImpl();
//
//		setservice.get(setForm, msg);
//		if(msg.getErrCode() != GlbFinal.ERRCODE_SUCCESS) 
//		{
//			HtmlMessageBox hmb = new HtmlMessageBox();
//			hmb.setAlertType(HtmlMessageBox.ALERTTYPE_CALLALERTMETHOD);
//			hmb.setPrintMessage(msg.getMsg());
//			hmb.setForwardUrl("javascript:history.go(-1)");
//			return showMsg(hmb , request , response , mapping);
//		}

		//取得当前浏览会员信息
		Integer userID = (Integer)request.getSession().getAttribute(GlbFinal.SESSION_USERID);
		if(userID == null){
			userID = 0;
		}
		
		//判断当前浏览会员是否是好友
		FriendServiceImpl friendservice = new FriendServiceImpl();
		FriendForm friendForm = new FriendForm();
		
		friendForm.setPage(new PageCtr(1, 2, "N", " 1=1 "));
		friendForm.setQryUserID(theForm.getUserID());
		friendForm.setQryFriendID(userID);
		
		List firendlist = friendservice.adlist(friendForm, msg);
		if(msg.getErrCode() == GlbFinal.ERRCODE_SUCCESS && firendlist.size() > 0) 
		{
			BaseFriend base = (BaseFriend)firendlist.get(0);
			request.setAttribute("isFriend" , GlbFinal.YES);	
		}else{
			msg.setErrCode(GlbFinal.ERRCODE_SUCCESS);
			request.setAttribute("isFriend" , GlbFinal.NO);	
		}
		
		//判断是否是邻居
		LinjuServiceImpl linjuservice = new LinjuServiceImpl();
		
		LinjuForm linjuForm = new LinjuForm();
		
		linjuForm.setUserID(theForm.getUserID());
		linjuForm.setLinjuID(userID);
		
		linjuservice.get(linjuForm, msg);
		if(msg.getErrCode() == GlbFinal.ERRCODE_SUCCESS && linjuForm.getStatus().equals(GlbFinal.STS_NORMAL)) 
		{
			request.setAttribute("isLinju" , GlbFinal.YES);	
		}else{
			request.setAttribute("isLinju" , GlbFinal.NO);	
		}
		msg.setErrCode(GlbFinal.ERRCODE_SUCCESS);
		
		
		//取得我的系统资料
		UserSysinfoServiceImpl sysinfoservice = new UserSysinfoServiceImpl();
		UserSysinfoForm sysinfoForm = new UserSysinfoForm();
		
		sysinfoForm.setUserID(theForm.getUserID());
		
		sysinfoservice.home(sysinfoForm);
		request.setAttribute("sysinfo" , sysinfoForm);	
		
		//取得我的基本资料
		service.get(theForm, msg);
		if(msg.getErrCode() != GlbFinal.ERRCODE_SUCCESS) 
		{
			HtmlMessageBox hmb = new HtmlMessageBox();
			hmb.setAlertType(HtmlMessageBox.ALERTTYPE_CALLALERTMETHOD);
			hmb.setPrintMessage(msg.getMsg());
			hmb.setForwardUrl("javascript:history.go(-1)");
			return showMsg(hmb , request , response , mapping);
		}			
		request.setAttribute("theForm" , theForm);	
		
		//取得我的详细资料
		DetailsServiceImpl detailservice = new DetailsServiceImpl();
		DetailsForm detailform = new DetailsForm();
		
		detailform.setUserID(theForm.getUserID());
		detailservice.get(detailform, msg);
		if(msg.getErrCode() != GlbFinal.ERRCODE_SUCCESS) 
		{
			HtmlMessageBox hmb = new HtmlMessageBox();
			hmb.setAlertType(HtmlMessageBox.ALERTTYPE_CALLALERTMETHOD);
			hmb.setPrintMessage(msg.getMsg());
			hmb.setForwardUrl("javascript:history.go(-1)");
			return showMsg(hmb , request , response , mapping);
		}			
		BeanUtils.copyProperties(theForm, detailform);
				
//		request.setAttribute("detailform" , detailform);	
		
		//取得我的居住信息
		UserHomeServiceImpl userhomeservice = new UserHomeServiceImpl();
		UserHomeForm userhomeForm = new UserHomeForm();
		
		userhomeForm.setUserID(theForm.getUserID());
		
		userhomeservice.getbyuserID(userhomeForm, msg);
		if(msg.getErrCode() != GlbFinal.ERRCODE_SUCCESS) 
		{
			HtmlMessageBox hmb = new HtmlMessageBox();
			hmb.setAlertType(HtmlMessageBox.ALERTTYPE_CALLALERTMETHOD);
			hmb.setPrintMessage(msg.getMsg());
			hmb.setForwardUrl("javascript:history.go(-1)");
			return showMsg(hmb , request , response , mapping);
		}	
		BeanUtils.copyProperties(theForm, userhomeForm);
		
//		request.setAttribute("userhome" , userhomeForm);		
		
		//取得我的联系资料
		ContactsServiceImpl contactserice = new ContactsServiceImpl();
		ContactsForm contactform = new ContactsForm();
		
		contactform.setUserID(theForm.getUserID());
		
		contactserice.get(contactform, msg);
		if(msg.getErrCode() != GlbFinal.ERRCODE_SUCCESS) 
		{
			HtmlMessageBox hmb = new HtmlMessageBox();
			hmb.setAlertType(HtmlMessageBox.ALERTTYPE_CALLALERTMETHOD);
			hmb.setPrintMessage(msg.getMsg());
			hmb.setForwardUrl("javascript:history.go(-1)");
			return showMsg(hmb , request , response , mapping);
		}
		BeanUtils.copyProperties(theForm, contactform);		
//		request.setAttribute("contactform" , contactform);		
		
		//取得当前会员所在的社区
		userhomeForm.Clear();
		userhomeForm.setUserID(userID);

		userhomeservice.getbyuserID(userhomeForm, msg);
		if(msg.getErrCode() != GlbFinal.ERRCODE_SUCCESS) 
		{
			HtmlMessageBox hmb = new HtmlMessageBox();
			hmb.setAlertType(HtmlMessageBox.ALERTTYPE_CALLALERTMETHOD);
			hmb.setPrintMessage(msg.getMsg());
			hmb.setForwardUrl("javascript:history.go(-1)");
			return showMsg(hmb , request , response , mapping);
		}	
		int cuIDvid = userhomeForm.getVillageID();
		request.setAttribute("cuIDvid" , cuIDvid);		
		
		//取得我的日志
		BlogServiceImpl blogservice = new BlogServiceImpl();
		BlogForm blogform = new BlogForm();
		
		blogform.setPage(new PageCtr(1, 7, "N", " 1=1 "));
		blogform.setQryUserID(theForm.getUserID());
		
		List bloglist = blogservice.list(blogform, msg);
		if(msg.getErrCode() != GlbFinal.ERRCODE_SUCCESS) 
		{
			HtmlMessageBox hmb = new HtmlMessageBox();
			hmb.setAlertType(HtmlMessageBox.ALERTTYPE_CALLALERTMETHOD);
			hmb.setPrintMessage(msg.getMsg());
			hmb.setForwardUrl("javascript:history.go(-1)");
			return showMsg(hmb , request , response , mapping);
		}		
		request.setAttribute("bloglist", bloglist);		
						
		//取得我的部落
		GMemberServiceImpl gmemberservice = new GMemberServiceImpl();
		GMemberForm gmemberform = new GMemberForm();
		
		gmemberform.setPage(new PageCtr(1, 10, "N", " 1=1 "));
		gmemberform.setQryUserID(theForm.getUserID());
		
		List mygrouplist = gmemberservice.adlist(gmemberform, msg);
		if(msg.getErrCode() != GlbFinal.ERRCODE_SUCCESS) 
		{
			HtmlMessageBox hmb = new HtmlMessageBox();
			hmb.setAlertType(HtmlMessageBox.ALERTTYPE_CALLALERTMETHOD);
			hmb.setPrintMessage(msg.getMsg());
			hmb.setForwardUrl("javascript:history.go(-1)");
			return showMsg(hmb , request , response , mapping);
		}		
		request.setAttribute("mygrouplist", mygrouplist);			
		
		//取得我参加的活动
		
		//取得最新留言
		NotAdvServiceImpl notadvservice = new NotAdvServiceImpl();
		NotAdvForm notadvform = new NotAdvForm();
		
		notadvform.setPage(new PageCtr(1, 2, "N", " 1=1 "));
		notadvform.setQryNtype(GlbFinal.NTYPE_LIUYAN);
		notadvform.setQryNsort(GlbFinal.NSORT_GERENZHUYE);
		notadvform.setQryNsortID(theForm.getUserID());
		
		List liuyanlist = notadvservice.adlist(notadvform, msg);
		if(msg.getErrCode() != GlbFinal.ERRCODE_SUCCESS) 
		{
			HtmlMessageBox hmb = new HtmlMessageBox();
			hmb.setAlertType(HtmlMessageBox.ALERTTYPE_CALLALERTMETHOD);
			hmb.setPrintMessage(msg.getMsg());
			hmb.setForwardUrl("javascript:history.go(-1)");
			return showMsg(hmb , request , response , mapping);
		}			
		request.setAttribute("liuyanlist", liuyanlist);			
		
		//取得我的邻居		

		LinjuForm linjuform = new LinjuForm();
		
		PageCtr page = new PageCtr(1, 36, "N", " 1=1 ");
		linjuform.setPage(page);
		linjuform.setQryUserID(theForm.getUserID());
		
		List linjulist = linjuservice.adlist(linjuform, msg);
		if(msg.getErrCode() != GlbFinal.ERRCODE_SUCCESS) 
		{
			HtmlMessageBox hmb = new HtmlMessageBox();
			hmb.setAlertType(HtmlMessageBox.ALERTTYPE_CALLALERTMETHOD);
			hmb.setPrintMessage(msg.getMsg());
			hmb.setForwardUrl("javascript:history.go(-1)");
			return showMsg(hmb , request , response , mapping);
		}		
		request.setAttribute("linjulist", linjulist);

		
		//取得我的好友
		friendForm.Clear();
		friendForm.setQryUserID(theForm.getUserID());
		friendForm.setPage(page);
		
		List friendlist = friendservice.adlist(friendForm, msg);
		if(msg.getErrCode() != GlbFinal.ERRCODE_SUCCESS) 
		{
			HtmlMessageBox hmb = new HtmlMessageBox();
			hmb.setAlertType(HtmlMessageBox.ALERTTYPE_CALLALERTMETHOD);
			hmb.setPrintMessage(msg.getMsg());
			hmb.setForwardUrl("javascript:history.go(-1)");
			return showMsg(hmb , request , response , mapping);
		}			
		request.setAttribute("friendlist", friendlist);
		
		//登记个人主页访问记录
		if(theForm.getUserID() != userID && userID != 0){
			VistorLogServiceImpl vistorservice = new VistorLogServiceImpl();
			VistorLogForm vistorForm = new VistorLogForm();
			
			vistorForm.setUserID(theForm.getUserID());
			vistorForm.setVistorID(userID);
			
			vistorservice.add(vistorForm, msg);
			if(msg.getErrCode() != GlbFinal.ERRCODE_SUCCESS) 
			{
				HtmlMessageBox hmb = new HtmlMessageBox();
				hmb.setAlertType(HtmlMessageBox.ALERTTYPE_CALLALERTMETHOD);
				hmb.setPrintMessage(msg.getMsg());
				hmb.setForwardUrl("javascript:history.go(-1)");
				return showMsg(hmb , request , response , mapping);
			}				
		}
		
		//我的相册
		GAlbumServiceImpl albumservice = new GAlbumServiceImpl();
		GAlbumForm albumForm = new GAlbumForm();
		
		albumForm.setPage(new PageCtr(1, 8, "N", " 1=1 "));
		albumForm.setQryGroupID(GlbFinal.PUBLICID);
		albumForm.setQryUserID(theForm.getUserID());
		
		List albumlist = albumservice.adlist(albumForm, msg);
		if(msg.getErrCode() != GlbFinal.ERRCODE_SUCCESS) 
		{
			HtmlMessageBox hmb = new HtmlMessageBox();
			hmb.setAlertType(HtmlMessageBox.ALERTTYPE_CALLALERTMETHOD);
			hmb.setPrintMessage(msg.getMsg());
			hmb.setForwardUrl("javascript:history.go(-1)");
			return showMsg(hmb , request , response , mapping);
		}		
		request.setAttribute("albumlist", albumlist);	
		
		return mapping.findForward(HOME_FORWARD);
	}	
	/**
	 *用户登陆后首页
	 */
	public ActionForward main(ActionMapping mapping, ActionForm form,
							 HttpServletRequest request , 
							 HttpServletResponse response)
		throws Exception
	{
		UsersForm theForm = (UsersForm) form;
		Integer userID = (Integer)request.getSession().getAttribute(GlbFinal.SESSION_USERID);
			
		if(userID == null || userID == 0 ){
			return mapping.findForward(LOGIN_FORWARD);
		}
		ReturnMessage msg  = new ReturnMessage();
		theForm.setUserID(userID);
		//System.out.println("**************************************");
		//System.out.println(System.getProperty("java.library.path"));
		//System.out.println("**************************************");
		service.get(theForm, msg);
		if(msg.getErrCode() != GlbFinal.ERRCODE_SUCCESS) 
		{
			HtmlMessageBox hmb = new HtmlMessageBox();
			hmb.setAlertType(HtmlMessageBox.ALERTTYPE_CALLALERTMETHOD);
			hmb.setPrintMessage(msg.getMsg());
			hmb.setForwardUrl("javascript:history.go(-1)");
			return showMsg(hmb , request , response , mapping);
		}		
		theForm.setPassword(Decode.Decode(theForm.getPassword()));
			
		//取得我的系统资料
		UserSysinfoServiceImpl sysinfoservice = new UserSysinfoServiceImpl();
		UserSysinfoForm sysinfoForm = new UserSysinfoForm();
		
		sysinfoForm.setUserID(theForm.getUserID());
		
		sysinfoservice.home(sysinfoForm);
		
		request.setAttribute("sysinfo" , sysinfoForm);	
		
		//取得我的资料
		UsersServiceImpl usersservice = new UsersServiceImpl();
		UsersForm usersfrom=new UsersForm();
		
		usersfrom.setPage(new PageCtr(1, 7, "N", " 1=1 "));
		usersfrom.setUserID(theForm.getUserID());
		
		List userslist = usersservice.adlist(usersfrom, msg);
		if(msg.getErrCode() != GlbFinal.ERRCODE_SUCCESS) 
		{
			HtmlMessageBox hmb = new HtmlMessageBox();
			hmb.setAlertType(HtmlMessageBox.ALERTTYPE_CALLALERTMETHOD);
			hmb.setPrintMessage(msg.getMsg());
			hmb.setForwardUrl("javascript:history.go(-1)");
			return showMsg(hmb , request , response , mapping);
		}		
		request.setAttribute("userslist", userslist);
		
		//取得我的详细资料
		UsersServiceImpl usersservice1 = new UsersServiceImpl();
		UsersForm usersfrom1=new UsersForm();
		
		usersfrom.setPage(new PageCtr(1, 7, "N", " 1=1 "));
		usersfrom.setUserID(theForm.getUserID());
		
		String[] interest = usersservice1.getinterest(usersfrom, msg);

		
		if(msg.getErrCode() != GlbFinal.ERRCODE_SUCCESS) 
		{
			HtmlMessageBox hmb = new HtmlMessageBox();
			hmb.setAlertType(HtmlMessageBox.ALERTTYPE_CALLALERTMETHOD);
			hmb.setPrintMessage(msg.getMsg());
			hmb.setForwardUrl("javascript:history.go(-1)");
			return showMsg(hmb , request , response , mapping);
		}		
		request.setAttribute("interest", interest[0]);
		request.setAttribute("interestSet", interest[1]);
		
		//取得我的邻居
		LinjuServiceImpl linjuservice = new LinjuServiceImpl();
		LinjuForm linjuform = new LinjuForm();
		
		PageCtr page = new PageCtr(1, 6, "N", " 1=1 ");
		linjuform.setPage(page);
		linjuform.setQryUserID(theForm.getUserID());
		
		List linjulist = linjuservice.adlist(linjuform, msg);
		if(msg.getErrCode() != GlbFinal.ERRCODE_SUCCESS) 
		{
			HtmlMessageBox hmb = new HtmlMessageBox();
			hmb.setAlertType(HtmlMessageBox.ALERTTYPE_CALLALERTMETHOD);
			hmb.setPrintMessage(msg.getMsg());
			hmb.setForwardUrl("javascript:history.go(-1)");
			return showMsg(hmb , request , response , mapping);
		}		
		request.setAttribute("linjulist", linjulist);
		
		//取得邻居动态
		OperLogServiceImpl operlogservice = new OperLogServiceImpl();
		OperLogForm operlogForm = new OperLogForm();
		
		operlogForm.setPage(new PageCtr(1, 5, "N", " 1=1 "));
		operlogForm.setQryUserID(theForm.getUserID());
		
		List linjuloglist = operlogservice.linjulist(operlogForm, msg);
		for(int i = 0;i<linjuloglist.size();i++) {
			Baseoperlog log = (Baseoperlog)linjuloglist.get(i);
			log.getContent2();
		}
		if(msg.getErrCode() != GlbFinal.ERRCODE_SUCCESS) 
		{
			HtmlMessageBox hmb = new HtmlMessageBox();
			hmb.setAlertType(HtmlMessageBox.ALERTTYPE_CALLALERTMETHOD);
			hmb.setPrintMessage(msg.getMsg());
			hmb.setForwardUrl("javascript:history.go(-1)");
			return showMsg(hmb , request , response , mapping);
		}		
		request.setAttribute("linjuloglist", linjuloglist);	
		
		//取得好友动态
		List friendloglist = operlogservice.friendlist(operlogForm, msg);
		for(int i = 0;i<friendloglist.size();i++) {
			Baseoperlog log = (Baseoperlog)friendloglist.get(i);
			log.getContent2();
		}
		if(msg.getErrCode() != GlbFinal.ERRCODE_SUCCESS) 
		{
			HtmlMessageBox hmb = new HtmlMessageBox();
			hmb.setAlertType(HtmlMessageBox.ALERTTYPE_CALLALERTMETHOD);
			hmb.setPrintMessage(msg.getMsg());
			hmb.setForwardUrl("javascript:history.go(-1)");
			return showMsg(hmb , request , response , mapping);
		}		
		request.setAttribute("friendloglist", friendloglist);				
		
		//取得部落动态
		List grouploglist = operlogservice.grouplist(operlogForm, msg);
		if(msg.getErrCode() != GlbFinal.ERRCODE_SUCCESS) 
		{
			HtmlMessageBox hmb = new HtmlMessageBox();
			hmb.setAlertType(HtmlMessageBox.ALERTTYPE_CALLALERTMETHOD);
			hmb.setPrintMessage(msg.getMsg());
			hmb.setForwardUrl("javascript:history.go(-1)");
			return showMsg(hmb , request , response , mapping);
		}		
		request.setAttribute("grouploglist", grouploglist);			
		
		//取得社区动态
		operlogForm.Clear();
		operlogForm.setPage(new PageCtr(1, 3, "N", " 1=1 "));
		operlogForm.setQryUserID(theForm.getUserID());

		List shequloglist = operlogservice.shequlist(operlogForm, msg);
		if(msg.getErrCode() != GlbFinal.ERRCODE_SUCCESS) 
		{
			HtmlMessageBox hmb = new HtmlMessageBox();
			hmb.setAlertType(HtmlMessageBox.ALERTTYPE_CALLALERTMETHOD);
			hmb.setPrintMessage(msg.getMsg());
			hmb.setForwardUrl("javascript:history.go(-1)");
			return showMsg(hmb , request , response , mapping);
		}		
		request.setAttribute("shequloglist", shequloglist);			
		
		//取得我的好友
		FriendServiceImpl friendservice = new FriendServiceImpl();
		FriendForm friednform = new FriendForm();

		friednform.Clear();
		friednform.setQryUserID(theForm.getUserID());
		friednform.setPage(page);
		
		List friendlist = friendservice.adlist(friednform, msg);
		if(msg.getErrCode() != GlbFinal.ERRCODE_SUCCESS) 
		{
			HtmlMessageBox hmb = new HtmlMessageBox();
			hmb.setAlertType(HtmlMessageBox.ALERTTYPE_CALLALERTMETHOD);
			hmb.setPrintMessage(msg.getMsg());
			hmb.setForwardUrl("javascript:history.go(-1)");
			return showMsg(hmb , request , response , mapping);
		}			
		request.setAttribute("friendlist", friendlist);
		
		//取得我的部落
		GMemberServiceImpl gmemberservice = new GMemberServiceImpl();
		GMemberForm gmemberform = new GMemberForm();
		
		gmemberform.setPage(new PageCtr(1, 10, "N", " 1=1 "));
		gmemberform.setQryUserID(theForm.getUserID());
		
		List mygrouplist = gmemberservice.adlist(gmemberform, msg);
		if(msg.getErrCode() != GlbFinal.ERRCODE_SUCCESS) 
		{
			HtmlMessageBox hmb = new HtmlMessageBox();
			hmb.setAlertType(HtmlMessageBox.ALERTTYPE_CALLALERTMETHOD);
			hmb.setPrintMessage(msg.getMsg());
			hmb.setForwardUrl("javascript:history.go(-1)");
			return showMsg(hmb , request , response , mapping);
		}		
		request.setAttribute("grouplist", mygrouplist);				
		
		//取得谁来看过我
		VistorLogServiceImpl vistorservice = new VistorLogServiceImpl();
		VistorLogForm vistorForm = new VistorLogForm();
		
		vistorForm.setUserID(theForm.getUserID());
		
		List vistorlist = vistorservice.list(theForm.getUserID(), 4);
		request.setAttribute("vistorlist", vistorlist);		

		
		//取得最新留言
		NotAdvServiceImpl notadvservice = new NotAdvServiceImpl();
		NotAdvForm notadvform = new NotAdvForm();
		
		notadvform.setPage(new PageCtr(1, 2, "N", " 1=1 "));
		notadvform.setQryNtype(GlbFinal.NTYPE_LIUYAN);
		notadvform.setQryNsort(GlbFinal.NSORT_GERENZHUYE);
		notadvform.setQryNsortID(theForm.getUserID());
		
		List liuyanlist = notadvservice.adlist(notadvform, msg);
		if(msg.getErrCode() != GlbFinal.ERRCODE_SUCCESS) 
		{
			HtmlMessageBox hmb = new HtmlMessageBox();
			hmb.setAlertType(HtmlMessageBox.ALERTTYPE_CALLALERTMETHOD);
			hmb.setPrintMessage(msg.getMsg());
			hmb.setForwardUrl("javascript:history.go(-1)");
			return showMsg(hmb , request , response , mapping);
		}			
		request.setAttribute("liuyanlist", liuyanlist);		

		//取得站内短信
		MessageServiceImpl msgservice = new MessageServiceImpl();
		MessageForm msgForm = new MessageForm();
		
		msgForm.setPage(new PageCtr(1, 2, "N", " 1=1 "));
		msgForm.setQryReceiver(theForm.getUserID());
		
		List msglist = msgservice.adlist(msgForm, msg);
		for(int i = 0;i<msglist.size();i++) {
			BaseMessage temp = (BaseMessage)msglist.get(i);
			if("1".equals(temp.getMtype()) || "2".equals(temp.getMtype())) {
				msglist.remove(temp);
			}
		}
		if(msg.getErrCode() != GlbFinal.ERRCODE_SUCCESS) 
		{
			HtmlMessageBox hmb = new HtmlMessageBox();
			hmb.setAlertType(HtmlMessageBox.ALERTTYPE_CALLALERTMETHOD);
			hmb.setPrintMessage(msg.getMsg());
			hmb.setForwardUrl("javascript:history.go(-1)");
			return showMsg(hmb , request , response , mapping);
		}			
		request.setAttribute("msglist", msglist);		
		
		//获取私聊的记录数
		int msgNum = msgservice.getMsgNum(String.valueOf(theForm.getUserID()));
		request.setAttribute("msgNum", msgNum);

		//取得居住信息
		UserHomeServiceImpl userhomeservice = new UserHomeServiceImpl();		
		UserHomeForm userhomeForm = new UserHomeForm();
		
		userhomeForm.Clear();
		userhomeForm = userhomeservice.list(theForm.getUserID());
		BeanUtils.copyProperties(theForm, userhomeForm);
		
		//取得详细资料
		DetailsServiceImpl detailservice = new DetailsServiceImpl();		
		DetailsForm detailForm = detailservice.list(theForm.getUserID());
		
		BeanUtils.copyProperties(theForm, detailForm);
		
		//取得联系资料
		ContactsServiceImpl contactservice = new ContactsServiceImpl();
		ContactsForm contactForm = contactservice.list(theForm.getUserID());

		BeanUtils.copyProperties(theForm, contactForm);

		request.setAttribute("theForm", theForm);	
		
		//取得社区业委、物业的最新通知和公告
		notadvform.Clear();
		notadvform.setQryVillageID(theForm.getVillageID());
		notadvform.setPage(new PageCtr(1, 2, "N", " 1=1 "));
		
		List notadvlist = notadvservice.shequlist(notadvform, msg);
		if(msg.getErrCode() != GlbFinal.ERRCODE_SUCCESS) 
		{
			HtmlMessageBox hmb = new HtmlMessageBox();
			hmb.setAlertType(HtmlMessageBox.ALERTTYPE_CALLALERTMETHOD);
			hmb.setPrintMessage(msg.getMsg());
			hmb.setForwardUrl("javascript:history.go(-1)");
			return showMsg(hmb , request , response , mapping);
		}			
		request.setAttribute("notadvlist", notadvlist);		
		
		//取得我的日志
		BlogServiceImpl blogservice = new BlogServiceImpl();
		BlogForm blogform = new BlogForm();
		
		blogform.setPage(new PageCtr(1, 7, "N", " 1=1 "));
		blogform.setQryUserID(theForm.getUserID());
		
		List bloglist = blogservice.list(blogform, msg);
		if(msg.getErrCode() != GlbFinal.ERRCODE_SUCCESS) 
		{
			HtmlMessageBox hmb = new HtmlMessageBox();
			hmb.setAlertType(HtmlMessageBox.ALERTTYPE_CALLALERTMETHOD);
			hmb.setPrintMessage(msg.getMsg());
			hmb.setForwardUrl("javascript:history.go(-1)");
			return showMsg(hmb , request , response , mapping);
		}		
		request.setAttribute("bloglist", bloglist);	
				
		//我的相册
		GAlbumServiceImpl albumservice = new GAlbumServiceImpl();
		GAlbumForm albumForm = new GAlbumForm();
		
		albumForm.setPage(new PageCtr(1, 4, "N", " 1=1 "));
		albumForm.setQryGroupID(GlbFinal.PUBLICID);
		albumForm.setQryUserID(theForm.getUserID());
		
		List albumlist = albumservice.adlist(albumForm, msg);
		if(msg.getErrCode() != GlbFinal.ERRCODE_SUCCESS) 
		{
			HtmlMessageBox hmb = new HtmlMessageBox();
			hmb.setAlertType(HtmlMessageBox.ALERTTYPE_CALLALERTMETHOD);
			hmb.setPrintMessage(msg.getMsg());
			hmb.setForwardUrl("javascript:history.go(-1)");
			return showMsg(hmb , request , response , mapping);
		}		
		request.setAttribute("albumlist", albumlist);	
		
		//取得社区当日加入人员
		String ctime = DatetimeUtil.getDateByadd(DatetimeUtil.getDatetime(), Calendar.DAY_OF_YEAR
				,-1	,"yyyyMMddhhmmss");
		
		userhomeForm.Clear();
		userhomeForm.setPage(new PageCtr(1, 6, "N", " 1=1 "));
		userhomeForm.setQryVillageID(theForm.getVillageID());
		userhomeForm.setQryCtime(ctime);
		
		List newMlist = userhomeservice.listbyCtime(userhomeForm, msg);
		if(msg.getErrCode() != GlbFinal.ERRCODE_SUCCESS) 
		{
			HtmlMessageBox hmb = new HtmlMessageBox();
			hmb.setAlertType(HtmlMessageBox.ALERTTYPE_CALLALERTMETHOD);
			hmb.setPrintMessage(msg.getMsg());
			hmb.setForwardUrl("javascript:history.go(-1)");
			return showMsg(hmb , request , response , mapping);
		}			
		request.setAttribute("newMlist", newMlist);			
		request.setAttribute("newMemNum", userhomeForm.getPage().getTotalNum());		
	
		return mapping.findForward(MAIN_FORWARD);
	}	
	/**
	 *取得用户
	 */
	public ActionForward get(ActionMapping mapping, ActionForm form,
							 HttpServletRequest request , 
							 HttpServletResponse response)
		throws Exception
	{
		UsersForm theForm = (UsersForm) form;
		
//		int userID = (Integer)request.getSession().getAttribute(GlbFinal.SESSION_USERID);
//		if(userID <= 0){
//			return mapping.findForward(LOGIN_FORWARD);
//		}
//		theForm.setUserID(Integer.valueOf(userID));

		ReturnMessage msg  = new ReturnMessage();
		
		service.get(theForm, msg);
		if(msg.getErrCode() != GlbFinal.ERRCODE_SUCCESS) 
		{
			HtmlMessageBox hmb = new HtmlMessageBox();
			hmb.setAlertType(HtmlMessageBox.ALERTTYPE_CALLALERTMETHOD);
			hmb.setPrintMessage(msg.getMsg());
			hmb.setForwardUrl("javascript:history.go(-1)");
			return showMsg(hmb , request , response , mapping);
		}
		
		//取得居住信息
		UserHomeServiceImpl userhomeservice = new UserHomeServiceImpl();		
		UserHomeForm userhomeForm = new UserHomeForm();
		
		userhomeForm.Clear();
		userhomeForm = userhomeservice.list(theForm.getUserID());
		BeanUtils.copyProperties(theForm, userhomeForm);
		
		//取得详细资料
		DetailsServiceImpl detailservice = new DetailsServiceImpl();		
		DetailsForm detailForm = detailservice.list(theForm.getUserID());
		
		BeanUtils.copyProperties(theForm, detailForm);
		
		//取得联系资料
		ContactsServiceImpl contactservice = new ContactsServiceImpl();
		ContactsForm contactForm = contactservice.list(theForm.getUserID());

		BeanUtils.copyProperties(theForm, contactForm);

		request.setAttribute("theForm", theForm);	
		
		return mapping.findForward(OPER_FORWARD);
	}

	/**
	 * 跳转到显示页面
	 */
	public ActionForward modifyPage(ActionMapping mapping, ActionForm form,
			 				 	 HttpServletRequest request , 
			 				 	 HttpServletResponse response)  
		throws Exception
	{
	
		return get(mapping , form, request , response);
	}	
	/**
	 * 跳转到显示页面
	 */
	public ActionForward modifyPwd(ActionMapping mapping, ActionForm form,
			 				 	 HttpServletRequest request , 
			 				 	 HttpServletResponse response)  
		throws Exception
	{
	
		return get(mapping , form, request , response);
	}	
	/**
	 * 修改
	 */
	public ActionForward updpwd(ActionMapping mapping, ActionForm form,
							 	HttpServletRequest request , 
							 	HttpServletResponse response)
		throws Exception
	{

		UsersForm theForm = (UsersForm) form;

		ReturnMessage msg  = new ReturnMessage();
		
		/**
		 *这里只要赋值需要更新的值
		 */
		service.updateuser(theForm , msg);
		if(msg.getErrCode() != GlbFinal.ERRCODE_SUCCESS) 
		{
			HtmlMessageBox hmb = new HtmlMessageBox();
			hmb.setAlertType(HtmlMessageBox.ALERTTYPE_CALLALERTMETHOD);
			hmb.setPrintMessage(msg.getMsg());
			hmb.setForwardUrl("javascript:history.go(-1)");
			return showMsg(hmb , request , response , mapping);
		}else{
			msg.setMsg("密码修改成功！");
			HtmlMessageBox hmb = new HtmlMessageBox();
			hmb.setAlertType(HtmlMessageBox.ALERTTYPE_PRINTTOHTML);
			hmb.setPrintMessage(msg.getMsg());
			hmb.setForwardUrl(GlbFinal.FOLDER_INSTALL + "/users.do?action=main");
			return showMsg(hmb , request , response , mapping);			
		}
		
	}
	/**
	 *修改用户
	 */
	public ActionForward update(ActionMapping mapping, ActionForm form,
							 HttpServletRequest request , 
							 HttpServletResponse response)
		throws Exception
	{
		UsersForm theForm = (UsersForm) form;
		
		ReturnMessage msg  = new ReturnMessage();
		
		service.update(theForm, msg);
		if(msg.getErrCode() != GlbFinal.ERRCODE_SUCCESS) 
		{
			HtmlMessageBox hmb = new HtmlMessageBox();
			hmb.setAlertType(HtmlMessageBox.ALERTTYPE_CALLALERTMETHOD);
			hmb.setPrintMessage(msg.getMsg());
			hmb.setForwardUrl("javascript:history.go(-1)");
			return showMsg(hmb , request , response , mapping);
		}else{
			msg.setMsg("保存成功！");
			HtmlMessageBox hmb = new HtmlMessageBox();
			hmb.setAlertType(HtmlMessageBox.ALERTTYPE_PRINTTOHTML);
			hmb.setPrintMessage(msg.getMsg());
			hmb.setForwardUrl(GlbFinal.FOLDER_INSTALL + "/users.do?action=main");
			return showMsg(hmb , request , response , mapping);
		}
	}
	/**
	 *修改用户
	 */
	public ActionForward adupdate(ActionMapping mapping, ActionForm form,
							 HttpServletRequest request , 
							 HttpServletResponse response)
		throws Exception
	{
		UsersForm theForm = (UsersForm) form;
		
		ReturnMessage msg  = new ReturnMessage();
		
		service.updateuser(theForm, msg);
		if(msg.getErrCode() != GlbFinal.ERRCODE_SUCCESS) 
		{
			HtmlMessageBox hmb = new HtmlMessageBox();
			hmb.setAlertType(HtmlMessageBox.ALERTTYPE_CALLALERTMETHOD);
			hmb.setPrintMessage(msg.getMsg());
			hmb.setForwardUrl("javascript:history.go(-1)");
			return showMsg(hmb , request , response , mapping);
		}
		
		return adlist(mapping,form,request,response);
		
	}
	
	
	public ActionForward saveInterest(ActionMapping mapping, ActionForm form,
			 HttpServletRequest request , 
			 HttpServletResponse response) throws Exception {
		
		//保存爱好关注
		UsersForm theForm = (UsersForm) form;
		String interest = "";
		String[] interestArr = request.getParameterValues("chkboxinterest");
		for(int i = 0;i<interestArr.length;i++) {
			interest += interestArr[i] + ",";
		}
		if(!"".equals(interest)) {
			interest = interest.substring(0,interest.length()-1);
		}
		theForm.setInterest(interest);
		String userID = request.getSession().getAttribute(GlbFinal.SESSION_USERID).toString();
		theForm.setUserID(Integer.parseInt(userID));
		theForm.setInterestSet(request.getParameter("interestSet"));
		service.saveInterest(theForm);
		
		return this.main(mapping, form, request, response);
		
	}
	
	/**
	 *会员注册
	 */
	public ActionForward register(ActionMapping mapping, ActionForm form,
							 HttpServletRequest request , 
							 HttpServletResponse response)
		throws Exception
	{
		UsersForm theForm = (UsersForm) form;
		
		ReturnMessage msg  = new ReturnMessage();

		String certCode = (String)request.getSession().getAttribute("certCode");
		if(certCode == null || certCode.equals("")|| !certCode.equals(theForm.getCheckcode())){
			
			msg.setMsg("验证码不正确！");
			
			HtmlMessageBox hmb = new HtmlMessageBox();
			hmb.setAlertType(HtmlMessageBox.ALERTTYPE_CALLALERTMETHOD);
			hmb.setPrintMessage(msg.getMsg());
			hmb.setForwardUrl("javascript:history.go(-1)");
			return showMsg(hmb , request , response , mapping);
		}

		String acturl = service.register(theForm, msg);
		if(msg.getErrCode() != GlbFinal.ERRCODE_SUCCESS) 
		{
			HtmlMessageBox hmb = new HtmlMessageBox();
			hmb.setAlertType(HtmlMessageBox.ALERTTYPE_CALLALERTMETHOD);
			hmb.setPrintMessage(msg.getMsg());
			hmb.setForwardUrl("javascript:history.go(-1)");
			return showMsg(hmb , request , response , mapping);
		}
		request.setAttribute("theForm", theForm);
		request.setAttribute("acturl", acturl);
		
		return mapping.findForward(SENDMAIL_FORWARD);
	}
	
//	/**
//	 *快速申请通道增加用户，不需验证email 
//	 */
//	public ActionForward add(ActionMapping mapping, ActionForm form,
//							 HttpServletRequest request , 
//							 HttpServletResponse response)
//		throws Exception
//	{
//		UsersForm theForm = (UsersForm) form;
//		
//		ReturnMessage msg  = new ReturnMessage();
//
//		String certCode = (String)request.getSession().getAttribute("certCode");
//		
//		if(certCode == null || certCode.equals("")|| !certCode.equals(theForm.getCheckcode())){
//			
//			msg.setMsg("验证码不正确！");
//			
//			HtmlMessageBox hmb = new HtmlMessageBox();
//			hmb.setAlertType(HtmlMessageBox.ALERTTYPE_CALLALERTMETHOD);
//			hmb.setPrintMessage(msg.getMsg());
//			hmb.setForwardUrl("javascript:history.go(-1)");
//			return showMsg(hmb , request , response , mapping);
//		}
//		
//		String nexturl = theForm.getNexturl();
//		
//		if(nexturl == null || nexturl.equals("")){
//			
//			nexturl = "/details.do?action=modifyAboutme";
//		}
//
//		service.add(theForm, msg);
//		if(msg.getErrCode() != GlbFinal.ERRCODE_SUCCESS) 
//		{
//			HtmlMessageBox hmb = new HtmlMessageBox();
//			hmb.setAlertType(HtmlMessageBox.ALERTTYPE_CALLALERTMETHOD);
//			hmb.setPrintMessage(msg.getMsg());
//			hmb.setForwardUrl("javascript:history.go(-1)");
//			return showMsg(hmb , request , response , mapping);
//		}
//		request.setAttribute("theForm", theForm);
//		
//		request.getSession().setAttribute(GlbFinal.SESSION_USERID, theForm.getUserID());
//		request.getSession().setAttribute(GlbFinal.SESSION_NAME, theForm.getNick());
//		request.getSession().setAttribute(GlbFinal.SESSION_USERTYPE, theForm.getType());		
//		
//		HtmlMessageBox hmb = new HtmlMessageBox();
//		hmb.setAlertType(HtmlMessageBox.ALERTTYPE_DIRECT_GO);
//		hmb.setPrintMessage(msg.getMsg());
//		hmb.setForwardUrl(nexturl);
//		return showMsg(hmb , request , response , mapping);
//	}
//	
	/**
	 *重发激活邮件
	 */
	public ActionForward sendEmail(ActionMapping mapping, ActionForm form,
							 HttpServletRequest request , 
							 HttpServletResponse response)
		throws Exception
	{
		UsersForm theForm = (UsersForm) form;
		

		ReturnMessage msg  = new ReturnMessage();
		
		service.sendEmail(theForm, msg);
		if(msg.getErrCode() != GlbFinal.ERRCODE_SUCCESS) 
		{
			HtmlMessageBox hmb = new HtmlMessageBox();
			hmb.setAlertType(HtmlMessageBox.ALERTTYPE_CALLALERTMETHOD);
			hmb.setPrintMessage(msg.getMsg());
			hmb.setForwardUrl("javascript:history.go(-1)");
			return showMsg(hmb , request , response , mapping);
		}
		request.setAttribute("theForm", theForm);
		
		return mapping.findForward(RESENDMAIL_FORWARD);

	}	
	/**
	 *会员激活
	 */
	public ActionForward active(ActionMapping mapping, ActionForm form,
							 HttpServletRequest request , 
							 HttpServletResponse response)
		throws Exception
	{
		UsersForm theForm = (UsersForm) form;
		
		ReturnMessage msg  = new ReturnMessage();
		

		service.active(theForm, msg);
		if(msg.getErrCode() != GlbFinal.ERRCODE_SUCCESS) 
		{
			HtmlMessageBox hmb = new HtmlMessageBox();
			hmb.setAlertType(HtmlMessageBox.ALERTTYPE_CALLALERTMETHOD);
			hmb.setPrintMessage(msg.getMsg());
			hmb.setForwardUrl("javascript:history.go(-1)");
			return showMsg(hmb , request , response , mapping);
		}
			
		request.getSession().setAttribute(GlbFinal.SESSION_USERID, theForm.getUserID());
		request.getSession().setAttribute(GlbFinal.SESSION_NAME, theForm.getNick());
		request.getSession().setAttribute(GlbFinal.SESSION_USERTYPE, theForm.getType());
		
		//跳转到居住信息页面
		
		msg.setMsg("会员成功激活！");
		HtmlMessageBox hmb = new HtmlMessageBox();
		hmb.setAlertType(HtmlMessageBox.ALERTTYPE_PRINTTOHTML);
		hmb.setPrintMessage(msg.getMsg());
		hmb.setForwardUrl(GlbFinal.FOLDER_INSTALL + "/users.do?action=main");
		return showMsg(hmb , request , response , mapping);

	}	
	/**
	 * 跳转到明细页面
	 */
	public ActionForward sendpwd(ActionMapping mapping, ActionForm form,
		 	 					HttpServletRequest request , 
		 	 					HttpServletResponse response) 
		throws Exception
	{

		/**
		 *定义数据封装类保存提交的数据
		 */
		UsersForm theForm = (UsersForm)form;
		ReturnMessage msg  = new ReturnMessage();

		service.sendpwd(theForm , msg);
		if(msg.getErrCode() != GlbFinal.ERRCODE_SUCCESS) 
		{
			/**
			 * 出现错误,则调用如下方法把错误信息提示到客户端,该部分
			 * 是使用response.write方法把相关的html代码写到客户端浏览器
			 * 1.hmb.setAlertType 提示类型(对话框,页面.....)
			 * 2.hmb.setPrintMessage 提示显示的信息
			 * 3.hmb.setForwardUrl 提示后跳转的URL
			 */
			HtmlMessageBox hmb = new HtmlMessageBox();
			hmb.setAlertType(HtmlMessageBox.ALERTTYPE_CALLALERTMETHOD);
			hmb.setPrintMessage(msg.getMsg());
			hmb.setForwardUrl("javascript:history.go(-1)");
			return showMsg(hmb , request , response , mapping);
		}else{
			msg.setMsg("密码已经发送到注册邮箱！");
			HtmlMessageBox hmb = new HtmlMessageBox();
			hmb.setAlertType(HtmlMessageBox.ALERTTYPE_PRINTTOHTML);
			hmb.setPrintMessage(msg.getMsg());
			hmb.setForwardUrl(GlbFinal.FOLDER_INSTALL + "/index.jsp");
			return showMsg(hmb , request , response , mapping);
		}
	}		
}
